﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PluginInterface;
using Buccontrols;

namespace Buccaneer
{
    public class SetCommentTypesAction : PluginAction
    {
        public SetCommentTypesAction()
        {
            base.name = "setct";
            base.func = new ActionFunction(SetCommentTypes);
            base.pars.Add("commentTypes", "strings of 4 characters to match the beginning of console output separated by semicolons");
        }

        public static void SetCommentTypes(string[] args)
        {
            Options.ShownCommentTypes = new List<string>();
            Options.ShownCommentTypes.AddRange(args[0].Split(new string[] { "; ", ";" }, StringSplitOptions.RemoveEmptyEntries));
        }
    }

    public class AddToCommentTypesAction : PluginAction
    {
        public AddToCommentTypesAction()
        {
            base.name = "addct";
            base.func = new ActionFunction(AddToCommentTypes);
            base.pars.Add("commentType", "a string of 4 characters to match the beginning of console output");
        }

        public static void AddToCommentTypes(string[] args)
        {
            Options.ShownCommentTypes.Add(args[0]);
        }
    }

    public class RemoveFromCommentTypesAction : PluginAction
    {
        public RemoveFromCommentTypesAction()
        {
            base.name = "remct";
            base.func = new ActionFunction(RemoveFromCommentTypes);
            base.pars.Add("commentType", "a string of 4 characters to match the beginning of console output");
        }

        public static void RemoveFromCommentTypes(string[] args)
        {
            Options.WriteComment("(i) commentType: " + string.Join("; ", args));
            while (Options.ShownCommentTypes.Contains(args[0]))
            {
                Options.ShownCommentTypes.Remove(args[0]);
            }
        }
    }
}
